package me.zhengjie.modules.rest.enterprise;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.modules.domain.enterprise.EnterpriseAdministrativePenalty;
import me.zhengjie.modules.service.EnterpriseAdmPenService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("企业行政处罚api")
@RestController
@RequiredArgsConstructor
@RequestMapping("/enterAdmPen")
public class EnterpriseAdmPenController {

    private final EnterpriseAdmPenService enterpriseAdmPenService;

    @ApiOperation("根据企业名称查询行政处罚信息")
    @AnonymousAccess
    @GetMapping("/queryEnterpriseAdmPenByName")
    public Map<String,Object> queryEnterpriseAdmPenByName(String name,@RequestParam Integer pageNo,@RequestParam Integer pageSize){
        Map<String,Object> map=new HashMap<>();
        map.put("name",name);
        map.put("pageNo",(pageNo-1)*pageSize);
        map.put("pageSize",pageSize);
        List<EnterpriseAdministrativePenalty> list=enterpriseAdmPenService.queryEnterpriseAdmPenForPageByName(map);
        int total=enterpriseAdmPenService.queryEnterpriseAdmPenByNameToTotal(map);
        map=new HashMap<>();
        map.put("list",list);
        map.put("total",total);
        return map;
    }

}
